package com.focus.xyz.other.pages.tpytb;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

import java.util.List;

/**
 * Created by chenmeng on 2016/3/30.
 */
public class InsDetailPage {

    @FindBy(xpath = "//input[@name='applyNo']")
    private WebElement insNo;
    @FindBy(xpath = "//input[@name='beginDate']")
    private WebElement insBeginTime;

    @FindBy(xpath = "//input[@value='新增客户信息']")
    private WebElement addCustLink;

    @FindBy(xpath = "//table[@id=\"datatable3\"]/tbody/tr[2]")
    private WebElement carInfoRow;
    @FindBy(xpath = "//*[@id=\"submitButton\"]")
    private WebElement finishBtn;

    private List<WebElement> cols;

    /*public InsDetailPage(WebDriver driver){
        PageFactory.initElements(driver,this);
    }*/


    public void inputCarNo(String carNo) throws Exception{
        WebElement car = carInfoRow.findElement(By.xpath("td[2]/input"));
        car.sendKeys(carNo);
    }

    public void selectCarInfo() throws Exception{
        WebElement checkbox = carInfoRow.findElement(By.xpath("td[1]/input[1]"));
        checkbox.click();
    }
    public void inputSits(String sits) throws Exception{
        WebElement s = carInfoRow.findElement(By.xpath("td[3]/input"));
        s.sendKeys(sits);
    }

    public void openAddCustLink() throws Exception{
        this.addCustLink.click();
    }

    public void finish() throws Exception{
        this.finishBtn.click();
    }

    public String getInsNoId() throws Exception{
        return this.insNo.getAttribute("value");
    }
    public void setNewInsNoId(String insNoId) throws Exception{
        this.insNo.clear();
        this.insNo.sendKeys(insNoId);
    }

    public void inputInsBeginTime(String beginDate) throws Exception{
        this.insBeginTime.clear();
        this.insBeginTime.sendKeys(beginDate);
    }

}
